{include file = "styles/header.tpl"}
<link href="{$smarty.const.HOST_STATIC}/libs/js/calendar/calendar-mos.css" rel="stylesheet">
<script src="{$smarty.const.HOST_STATIC}/libs/js/calendar/calendar_mini.js"></script>
<script src="{$smarty.const.HOST_STATIC}/libs/js/calendar/init_cal.js"></script>
<script src="{$smarty.const.HOST_STATIC}/libs/js/calendar/lang/calendar-en.js"></script>
<div id="content" class="box">
	<h1>{if $arrResult}Edit holidays{else}Add holidays{/if}</h1>
	<br />
	<form id="form" name="form" action="" target="ifrm" method="post" onsubmit="return checkForm();">
			<table width="100%">
				<tr>
					<td width="15%"><strong>Holiday date:</strong></td>
					<td><input type="text" size="15" name="strDate" id="strDate" value="{$arrResult.date}" 
						onclick="return showCalendar('strDate', 'y-mm-dd');" />
						<span class="msg info">
							Date is unit.
						</span>
					</td>
				</tr>
				<tr>
					<td><strong>Weekday:</strong></td>
					<td><input type="text" value="{$arrResult.weekday}" size="15" name="strWeekday" id="strWeekday" readonly ="true"/></td>
				</tr>
				<tr>
					<td width="15%"><strong>Description:</strong></td>
					<td>
						<textarea name="strDescription" id="strDescription" rows="3" cols="32">{$arrResult.description}</textarea>
					</td>
				</tr>
				<tr>
					<td>&nbsp;</td>
					<td>
						<input type="hidden" name="intId" value="{$arrResult.id}" />
						<input type="submit" value="{if $arrResult}Update Holiday{else}Add holiday{/if}" class="bt" />
					</td>
				</tr>
			</table>
	</form>
	<iframe name="ifrm" id="ifrm" style="display:none"></iframe>
</div>
{literal}
<script type="text/javascript">
    $(document).ready(function(){
		hide_all_error();
	});

	$('#strDate').blur(function() {
		var date = new Date($('#strDate').val());
		var weekday=new Array(7);
		weekday[0]="sun";
		weekday[1]="mon";
		weekday[2]="tue";
		weekday[3]="wed";
		weekday[4]="thu";
		weekday[5]="fri";
		weekday[6]="sat";
		var n = weekday[date.getDay()]; 
		$("#strWeekday").val(n);
	});


	function checkForm()
	{
		hide_all_error();
		var iCheck	= 0;
		var eFocus	= '';
		
		var id		= 'strDate';
		var e		= $('#' + id);
		if( !e.val() )
		{
			iCheck 	= 1;
			eFocus	= eFocus ? eFocus : e;
			show_error(id, 'null');
		}

		if(iCheck==1)
		{
			eFocus.focus();
			return false;
		}
		showWaiting();
		return true;
	}
	
	function submit_done()
	{
		window.location.href	= HOST_ADMIN + '/holidays';
	}
</script>
{/literal}
{include file = "styles/footer.tpl"}